import IP from './IP'
import urlMap from './MapUrl';

class PostDataToServer{
    constructor(){

    }
    async PostData(_url){
        _url = urlMap(_url);
        const ipAdress = formatUrl(_url);
        params = params || {};
        const postData = {
            method:'POST',
            headers:{
                'Accept': 'application/json',
                'Content-Type': 'application/json',
            },
            body:JSON.stringify(pramas)
        }
        try {
            let response = await fetch(ipAdress);
            let responseJson = await response.json();
            return responseJson;
        } catch(error) {
            throw error;
        }
    }
}
export default new PostDataToServer().PostData;

function formatUrl(name) {
    let _url = '';
    while (name.indexOf('.') >= 0) {
        name = name.replace('.', '/');
    }
    _url = IP + name;
    return _url;
}